package com.cyh.testdesignpattern.state;

//活动
public class RaffleAction {
    State state = null;//当前活动的状态
    int count = 0; //奖品的数量


    //4中状态
    State noRaffleState = new NoRaffleState(this);
    State canReffleState = new CanRaffleState(this);
    State dispenseState = new DispenseState(this);
    State dispenseOutState = new DispenseOutState(this);

    public RaffleAction(int count) {
        this.count = count;
        this.state = getNoRaffleState();
    }


    //扣积分
    public void debuctMoney() {
        state.deductMoney();
    }

    //抽奖
    public void raffle() {
        //抽奖成功
        if(state.raffle()) {
            state.dispensePrize();
        }
    }

    //每领取一次奖品--
    public int getCount() {
        int curCount = count;
        count--;
        return curCount;
    }




    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }


    public void setCount(int count) {
        this.count = count;
    }

    public State getNoRaffleState() {
        return noRaffleState;
    }

    public void setNoRaffleState(State noRaffleState) {
        this.noRaffleState = noRaffleState;
    }

    public State getCanReffleState() {
        return canReffleState;
    }

    public void setCanReffleState(State canReffleState) {
        this.canReffleState = canReffleState;
    }

    public State getDispenseState() {
        return dispenseState;
    }

    public void setDispenseState(State dispenseState) {
        this.dispenseState = dispenseState;
    }

    public State getDispenseOutState() {
        return dispenseOutState;
    }

    public void setDispenseOutState(State dispenseOutState) {
        this.dispenseOutState = dispenseOutState;
    }
}
